2000W / 48V LLC Battery-Charger  V1.00
xmc_gpio.c
Go to the documentation of this file.
1 
49 /*******************************************************************************
50  * HEADER FILES
51  *******************************************************************************/
52 
53 #include <xmc_gpio.h>
54 
55 /*******************************************************************************
56  * MACROS
57  *******************************************************************************/
58 
59 #define PORT_HWSEL_Msk PORT0_HWSEL_HW0_Msk
60 
61 /*******************************************************************************
62  * API IMPLEMENTATION
63  *******************************************************************************/
64 
65 void XMC_GPIO_SetMode(XMC_GPIO_PORT_t *const port, const uint8_t pin, const XMC_GPIO_MODE_t mode)
66 {
67  XMC_ASSERT("XMC_GPIO_SetMode: Invalid port", XMC_GPIO_CHECK_PORT(port));
68  XMC_ASSERT("XMC_GPIO_SetMode: Invalid mode", XMC_GPIO_IsModeValid(mode));
69 
70  port->IOCR[(uint32_t)pin >> 2U] &= ~(uint32_t)((uint32_t)PORT_IOCR_PC_Msk << ((uint32_t)PORT_IOCR_PC_Size * ((uint32_t)pin & 0x3U)));
71  port->IOCR[(uint32_t)pin >> 2U] |= (uint32_t)mode << ((uint32_t)PORT_IOCR_PC_Size * ((uint32_t)pin & 0x3U));
72 }
73 
74 void XMC_GPIO_SetHardwareControl(XMC_GPIO_PORT_t *const port, const uint8_t pin, const XMC_GPIO_HWCTRL_t hwctrl)
75 {
76  XMC_ASSERT("XMC_GPIO_SetHardwareControl: Invalid port", XMC_GPIO_CHECK_PORT(port));
77  XMC_ASSERT("XMC_GPIO_SetHardwareControl: Invalid hwctrl", XMC_GPIO_CHECK_HWCTRL(hwctrl));
78 
79  port->HWSEL &= ~(uint32_t)((uint32_t)PORT_HWSEL_Msk << ((uint32_t)pin << 1U));
80  port->HWSEL |= (uint32_t)hwctrl << ((uint32_t)pin << 1U);
81 }
#define XMC_GPIO_CHECK_HWCTRL(hwctrl)
Definition: xmc_gpio.h:106
void XMC_GPIO_SetMode(XMC_GPIO_PORT_t *const port, const uint8_t pin, const XMC_GPIO_MODE_t mode)
Definition: xmc_gpio.c:65
enum XMC_GPIO_HWCTRL XMC_GPIO_HWCTRL_t
#define PORT_IOCR_PC_Msk
Definition: xmc_gpio.h:98
#define XMC_ASSERT(msg, exp)
Definition: xmc_common.h:132
#define PORT_HWSEL_Msk
Definition: xmc_gpio.c:59
void XMC_GPIO_SetHardwareControl(XMC_GPIO_PORT_t *const port, const uint8_t pin, const XMC_GPIO_HWCTRL_t hwctrl)
Definition: xmc_gpio.c:74
#define PORT_IOCR_PC_Size
Definition: xmc_gpio.h:100